﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using ConstructionBidOnline.Biz;
using com.dwolla.www;



using com.paypal.sdk.services;
using com.paypal.soap.api;
using com.paypal.sdk.profiles;

public partial class AddPaymentMethod : System.Web.UI.Page
{

    #region Event Handlers

    #region Page Load

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    #endregion

    #region Radio Button Payment Method Click

    protected void rblistpaymenttype_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (rblistpaymenttype.SelectedValue == "PayPal")
        {
            pnlpaypal.Visible = true;
            pnlDwolla.Visible = false;
            
        }

        if (rblistpaymenttype.SelectedValue == "Dwolla")
        {
            pnlpaypal.Visible = false;
            pnlDwolla.Visible = true;
        }
        
    }

    #endregion

    //#region Button Cancel Click

    //protected void bttncancel_Click(object sender, ImageClickEventArgs e)
    //{
    //    CallerServices caller = new CallerServices();

    //    IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();

    //    // Set up your API credentials, PayPal end point, and API version.
    //    profile.APIUsername = PayPalConstants.API_USERNAME;   //  "sdk-three_api1.sdk.com";
    //    profile.APIPassword = PayPalConstants.API_PASSWORD; // "QFZCWN5HZM8VBG7Q";
    //    profile.APISignature = PayPalConstants.API_SIGNATURE; // "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ";
    //    profile.Environment = PayPalConstants.ENVIRONMENT; // "sandbox";
    //    caller.APIProfile = profile;

    //    SetExpressCheckoutRequestType pp_request = new SetExpressCheckoutRequestType();
    //    pp_request.Version = "51.0";

    //    // Add request-specific fields to the request.
    //    // Create the request details object.
    //    pp_request.SetExpressCheckoutRequestDetails = new SetExpressCheckoutRequestDetailsType();
    //    pp_request.SetExpressCheckoutRequestDetails.PaymentAction = PaymentActionCodeType.Authorization;//Enum for PaymentAction is  PaymentActionCodeType.Sale
    //    pp_request.SetExpressCheckoutRequestDetails.PaymentActionSpecified = true;

    //    pp_request.SetExpressCheckoutRequestDetails.OrderTotal = new BasicAmountType();

    //    pp_request.SetExpressCheckoutRequestDetails.OrderTotal.currencyID = CurrencyCodeType.USD;//Enum for currency code is  CurrencyCodeType.USD
    //    pp_request.SetExpressCheckoutRequestDetails.OrderTotal.Value = "0";

    //    pp_request.SetExpressCheckoutRequestDetails.CancelURL = "";
    //    pp_request.SetExpressCheckoutRequestDetails.ReturnURL = "";

    //    // Execute the API operation and obtain the response.
    //    SetExpressCheckoutResponseType pp_response = new SetExpressCheckoutResponseType();
    //    pp_response = (SetExpressCheckoutResponseType)caller.Call("SetExpressCheckout", pp_request);
    //    //Response.Write(pp_request.SetExpressCheckoutRequestDetails);
    //}

    //#endregion

    //#region Button Add Credit Card Click

    //protected void bttnaddcredit_Click(object sender, ImageClickEventArgs e)
    //{
    //    if (txtcardnumber.Text.Length < 16)
    //    {
    //        lblerror.Visible = true;
    //        lblerror.Text = "Your credit card number should not be less 16 characters";
    //    }
    //    else
    //    {
    //        if (txtcvvnumber.Text.Length < 3)
    //        {
    //            lblerror.Visible = true;
    //            lblerror.Text = "Your cvv number should not be less 16 characters";
    //        }
    //        else
    //        {
    //            PaymentMethods paymentMethodObj = PaymentMethods.GetPaymentMethodByCardNumber(txtcardnumber.Text);
    //            if (paymentMethodObj == null)
    //            {
    //                PaymentMethods newpaymentMethodObj = PaymentMethods.CreateNew();
    //                newpaymentMethodObj.UserID = Int32.Parse(Session["userid"].ToString());
    //                newpaymentMethodObj.PaymentType = "Credit Card";
    //                newpaymentMethodObj.FinancialAccount = txtfinancialaccount.Text;
    //                newpaymentMethodObj.CardType = rcbcardtype.SelectedValue;
    //                newpaymentMethodObj.CardNumber = txtcardnumber.Text;
    //                newpaymentMethodObj.ExpirationMonth = rcbexpirymonth.SelectedValue;
    //                newpaymentMethodObj.ExpirationYear = rcbexpiryyear.SelectedValue;
    //                newpaymentMethodObj.CVVNumber = txtcvvnumber.Text;
    //                PaymentMethods.Update(newpaymentMethodObj);
    //                Response.Redirect("MyPayments.aspx");
    //            }
    //            else
    //            {
    //                lblerror.Visible = true;
    //                lblerror.Text = "Entered credit card number already in use";
    //            }
    //        }
    //    }

    //}

    //#endregion

    #endregion

}
